import io


class QTextBrowserStream(io.StringIO):
    def __init__(self, text_browser):
        super().__init__()
        self.text_browser = text_browser

    def write(self, text):
        # 每次写入内容时将其追加到 QTextBrowser 中
        self.text_browser.append(text.strip())  # 移除多余的换行

    def flush(self):
        pass